<template>
    <div class="bigbox">
        <div style="padding-top: 200px;" v-show="showloding">
            <van-loading size="50px" vertical>加载中...</van-loading>
        </div>
        <van-card v-for="item in list" :key="item" :desc="item.applicant" :title="item.number">
            <template #tags>
                <div>申请时间{{ item.applicationTime }}</div>
                <div>接收人：{{ item.recipient }}</div>
                <div>接收项目：{{ item.entryName }}</div>
            </template>
            <template #footer>
                <van-button size="mini" @click="pass(item)" v-show="bm == 2">同意</van-button>
                <van-button size="mini" @click="nopass(item)" v-show="bm == 2">拒绝</van-button>
            </template>
        </van-card>
        <van-empty description="暂无数据" v-show="list.length == 0" />
    </div>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import { showToast } from 'vant';
import { getsplist, submitSQ } from '../../sevce/user'
const showloding = ref(true)
//审批信息
const changefrom = ref({
    id: '',
    button_code: 4,
    approver: JSON.parse(localStorage.getItem('userinfo')).names,

})
//同意转移 
function pass(item) {
    changefrom.value.id = item.computerId
    submitSQ(changefrom.value).then((res) => {
        showToast('同意')
        getlist()
    })
}
//拒绝
function nopass(item) {
    changefrom.value.id = item.computerId
    changefrom.value.button_code = 5
    submitSQ(changefrom.value).then((res) => {
        showToast('驳回')
        getlist()
    })

}
//获取审批列表
const list = ref([])
function getlist() {
    getsplist().then((res) => {
        console.log(res)
        list.value = res.data
        showloding.value = false
    })
}
//bm
let bm = ref()
onMounted(() => {
    bm.value = JSON.parse(localStorage.getItem('userinfo')).position
    console.log(JSON.parse(localStorage.getItem('userinfo')))
    getlist()
})
</script>

<style lang="scss" scoped>
.bigbox {
    height: 90vh;
    overflow-y: scroll;
}
</style>